diff options
Diffstat (limited to 'frontend/app/drive/[...path]/page.tsx')
| -rw-r--r-- | frontend/app/drive/[...path]/page.tsx | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/frontend/app/drive/[...path]/page.tsx b/frontend/app/drive/[...path]/page.tsx index 8380a30..bfb65ad 100644 --- a/frontend/app/drive/[...path]/page.tsx +++ b/frontend/app/drive/[...path]/page.tsx | |||
| @@ -1,6 +1,27 @@ | |||
| 1 | import { DriveDirectoryView } from "@/components/drive/DriveDirectoryView" | 1 | import { DriveDirectoryView } from "@/components/drive/DriveDirectoryView" |
| 2 | import { Drive_ls } from "@/lib/drive_server" | 2 | import { Drive_ls } from "@/lib/drive_server" |
| 3 | 3 | ||
| 4 | async function fetchStorageData() { | ||
| 5 | try { | ||
| 6 | const response = await fetch(`${process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:3000' : ''}/api/storage`, { | ||
| 7 | cache: 'no-store' | ||
| 8 | }) | ||
| 9 | if (!response.ok) { | ||
| 10 | throw new Error('Failed to fetch storage data') | ||
| 11 | } | ||
| 12 | return await response.json() | ||
| 13 | } catch (error) { | ||
| 14 | console.error('Failed to fetch storage data:', error) | ||
| 15 | // Return zeros on error as requested | ||
| 16 | return { | ||
| 17 | activeDriveUsage: 0, | ||
| 18 | totalDiskCapacity: 0, | ||
| 19 | totalDiskUsed: 0, | ||
| 20 | availableDisk: 0 | ||
| 21 | } | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 4 | export default async function DriveDirectoryPage({ | 25 | export default async function DriveDirectoryPage({ |
| 5 | params, | 26 | params, |
| 6 | }: { | 27 | }: { |
| @@ -11,6 +32,10 @@ export default async function DriveDirectoryPage({ | |||
| 11 | const decodedSegments = pathSegments?.map(segment => decodeURIComponent(segment)) || [] | 32 | const decodedSegments = pathSegments?.map(segment => decodeURIComponent(segment)) || [] |
| 12 | const currentPath = '/' + decodedSegments.join('/') | 33 | const currentPath = '/' + decodedSegments.join('/') |
| 13 | 34 | ||
| 14 | const files = await Drive_ls(currentPath, false) | 35 | const [files, storageData] = await Promise.all([ |
| 15 | return <DriveDirectoryView path={currentPath} files={files} /> | 36 | Drive_ls(currentPath, false), |
| 37 | fetchStorageData() | ||
| 38 | ]) | ||
| 39 | |||
| 40 | return <DriveDirectoryView path={currentPath} files={files} storageData={storageData} /> | ||
| 16 | } \ No newline at end of file | 41 | } \ No newline at end of file |
